#ifndef _HAND_DIRVER_NODE_H_
#define _HAND_DIRVER_NODE_H_

#include <queue>
#include <iostream>
#include <cstring>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <signal.h>
#include <rclcpp/rclcpp.hpp>
#include <sensor_msgs/msg/joint_state.hpp>
#include <std_msgs/msg/float32.hpp>
#include <std_msgs/msg/float32_multi_array.hpp>
#include <std_msgs/msg/string.hpp>
#include <hand_driver/cscan.h>
#include <geometry_msgs/msg/vector3.hpp>
#include <hand_msgs/msg/set_param.hpp>  
#include <hand_msgs/msg/motor_state.hpp> 


// 添加 CANFD 地址宏定义
#define M_ADDR 0x010   // 电缸数据反馈地址
#define S_ADDR 0x011   // 传感器数据反馈地址
#define DT_ADDR 0x300  // 电缸数据设置地址
#define SS_ADDR 0x400  // 电缸使能地址

#define MOTOR_POS_MODE    0 // 电缸工作在位置模式
#define MOTOR_VEL_MODE    2 // 电缸工作在速度模式
#define MOTOR_TOR_MODE    1 // 电缸工作在力矩模式

typedef struct{
    float target_position;
    float actual_position;
    float target_velocity;
    float actual_velocity;
    float target_force;
    float actual_force; 
    float position_error;
    float force_error;
    float stator_current;
    float supply_voltage;
    float motor_temp;
    float transistor_temp;
    float error_code;
    
    int motor_mode;
}motor_t;

typedef struct{
    float preTOR;
    float preVEL;
    float prePOS;

    float actTOR;
    float actVEL;
    float actPOS;  
}joint_t;

typedef struct{
    float data;
}sensor_t;

#define _MOTOR_MAX  100 //18
#define _JOINT_MAX  100 //23
#define _SENSOR_MAX 100 //5

#define _SENSOR_DIM 3

#define _MOTOR_FRAME    48
#define _SENSOR_FRAME   16
#define _CTRL_FRAME     4

#define _MOTOR_MAILBOX  0
#define _SENSOR_MAILBOX 1

#endif //_HAND_DIRVER_NODE_H_    